<script>
/**
 * Recent activity component
 */
import journalModal from "@/components/journalModal";
export default {
  components: {
    journalModal
  },
  props: {
    type: {
      value: Number
    }
  },
  data() {
    return {
      activityData: [
        {
          icon: "ri-edit-2-fill",
          time: "刚刚",
          date: "",
          title: "ERROR-org.spiderflow.core.Spider - 执行节点[列表详情页临时表:18]出错,异常信息：{}"
        },
        {
          icon: "ri-user-2-fill",
          date: "",
          time: "刚刚",
          title: "ERROR-cn.edu.hfut.dmic.ContentExtractor - 抓取出错"
        },
        {
          icon: "ri-bar-chart-fill",
          date: "",
          time: "刚刚",
          title: "ERROR-org.RequestExecutor - 请求出错,异常信息:{}"
        },
        {
          icon: "ri-calendar-2-fill",
          date: "",
          time: "1分钟前",
          title: "ERROR org.RequestExecutor - 请求出错,异常信息:null"
        },
        {
          icon: "ri-edit-2-fill",
          date: "",
          time: "2分钟前",
          title: "ERROR SocketTimeoutException: 连接超时"
        },
        {
          icon: "ri-user-2-fill",
          date: "",
          time: "3分钟前",
          title: "ERROR  o.s.core.ExecuteSQLExecutor - 数据源ID为空"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "15分钟前",
          title: "ERROR java.NullPointerException: 空指针异常"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "30分钟前",
          title: "ERROR org.Spider - 抓取执行节点[执行SQL:19]出错,异常信息：{}"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "40分钟前",
          title: "ERROR java.IllegalArgumentException: URL地址无效"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "1小时前",
          title: "ERROR org.core.Spider - 抓取执行节点[开始抓取:14]出错,异常信息：{}"
        }
      ],
      // activityData: [
      //   {
      //     icon: "ri-edit-2-fill",
      //     date: "2022-01-25",
      //     time: "16:07",
      //     title: "get html failed reason Connection reset"
      //   },
      //   {
      //     icon: "ri-user-2-fill",
      //     date: "2022-01-25",
      //     time: "14:01",
      //     title: "get html failed reason Connection reset"
      //   },
      //   {
      //     icon: "ri-bar-chart-fill",
      //     date: "2022-01-25",
      //     time: "12:10",
      //     title: "get html failed reason Connection reset"
      //   },
      //   {
      //     icon: "ri-calendar-2-fill",
      //     date: "2022-01-25",
      //     time: "10:47",
      //     title: "get html failed reason Connection reset"
      //   },
      //   {
      //     icon: "ri-edit-2-fill",
      //     date: "2022-01-25",
      //     time: "9:09",
      //     title: "get html failed reason Connection reset"
      //   },
      //   {
      //     icon: "ri-user-2-fill",
      //     date: "2022-01-25",
      //     time: "8:07 am",
      //     title: "get html failed reason Connection reset"
      //   }
      // ]
    };
  },
  created () {
    if(this.type==2){
      this.activityData = [
        {
          icon: "ri-edit-2-fill",
          time: "刚刚",
          date: "",
          title: "ERROR cn.edu.ContentExtractor - 新闻内容提取出错"
        },
        {
          icon: "ri-user-2-fill",
          date: "",
          time: "1分钟前",
          title: "ERROR cn.edu.ContentExtractor - 新闻标题提取出错"
        },
        {
          icon: "ri-bar-chart-fill",
          date: "",
          time: "2分钟前",
          title: "ERROR 在org.HttpResponse中调用方法getHtml发生异常"
        },
        {
          icon: "ri-calendar-2-fill",
          date: "",
          time: "2分钟前",
          title: "ERROR o.VariableExecutor - 设置变量contenthtml出错"
        },
        {
          icon: "ri-edit-2-fill",
          date: "",
          time: "3分钟前",
          title: "ERROR java.lang.Exception: 时间找不到"
        },
        {
          icon: "ri-user-2-fill",
          date: "",
          time: "5分钟前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[结果发送:34]出错,异常信息：{}"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "30分钟前",
          title: "ERROR java.lang.reflect: 解析空指针异常"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "40分钟前",
          title: "ERROR java.Exception: 时间找不到"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "50分钟前",
          title: "ERROR org.spiderflow.Spider - 执行节点[结果发送:34]出错,异常信息：{}"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "1小时前",
          title: "ERROR java.lang.reflect: 空指针异常"
        }
      ]
    }
    if(this.type==3){
      this.activityData = [
        {
          icon: "ri-edit-2-fill",
          time: "2分钟前",
          date: "",
          title: "ERROR try.restarting.transaction: 超过锁等待超时；尝试重新启动事务"
        },
        {
          icon: "ri-user-2-fill",
          date: "",
          time: "2分钟前",
          title: "ERROR o.spiderflow.ResultSendUtil - kafka消息队列发送失败"
        },
        {
          icon: "ri-bar-chart-fill",
          date: "",
          time: "10分钟前",
          title: "ERROR try.restarting.transaction: 主键重复，插入异常"
        },
        {
          icon: "ri-calendar-2-fill",
          date: "",
          time: "30分钟前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[列表详情页临时表:18]出错,异常信息：{}"
        },
        {
          icon: "ri-edit-2-fill",
          date: "",
          time: "1小时前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[执行SQL:66]出错,异常信息：{}"
        },
        {
          icon: "ri-user-2-fill",
          date: "",
          time: "2小时前",
          title: "ERROR o.spiderflow.ResultSendUtil - kafka消息队列发送失败"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "2小时前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[执行SQL:67]出错,异常信息：{}"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "2小时前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[列表详情页临时表:25]出错,异常信息：{}"
        },
{
          icon: "ri-user-2-fill",
          date: "",
          time: "2小时前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[结果发送:34]出错,异常信息：{}"
        },{
          icon: "ri-user-2-fill",
          date: "",
          time: "2小时前",
          title: "ERROR org.spiderflow.core.Spider - 执行节点[结果发送:34]出错,异常信息：{}"
        }

      ]
    }
  },
  methods: {
    jump(){
      this.$router.push({
        path: '/log',
        query: {
          type: this.type==1?'采集异常':this.type==2?'解析异常':'存储异常'
        }
      })
    },
    logDetail(v){
      console.log(v);
      this.$refs.journalModal.open()
    }
  }
};
</script>

<template>
  <div class="card">
    <div class="card-body">
      <div class="float-right">
        <span style="cursor: pointer;">
          <i style="font-size: 18px;vertical-align: text-bottom;margin-right: 5px;" class="el-icon-refresh-right"></i>
        </span>
        
        <span style="cursor: pointer;" @click="jump">
          <span>查看更多</span>
          <i style="font-size: 15px;vertical-align: bottom;" class="ri-arrow-right-s-line"></i>
        </span>
      </div>

      <h4 v-if="type==1" class="card-title mb-4" style="font-size: 17px;">
        <!-- <i style="font-size: 20px;vertical-align: sub;" class="ri-file-excel-line"></i> -->
        <i style="font-size: 20px;vertical-align: bottom;" class="el-icon-folder-delete"></i>
        采集异常日志
      </h4>
      <h4 v-if="type==2" class="card-title mb-4" style="font-size: 17px;">
        <i style="font-size: 20px;vertical-align: sub;" class="ri-close-circle-line"></i>
        解析异常日志
      </h4>
      <h4 v-if="type==3" class="card-title mb-4" style="font-size: 17px;">
        <i style="font-size: 20px;vertical-align: sub;" class="ri-thunderstorms-line"></i>
        存储异常日志
      </h4>

      <div data-simplebar style="max-height: 410px;">
        <ul class="list-unstyled activity-wid">
          <li class="activity-list" v-for="(data, index) in activityData" :key="index">
            <div class="activity-icon avatar-xs">
              <span class="avatar-title bg-soft-primary text-primary rounded-circle">
                <!-- <i :class="`${data.icon}`"></i> -->
                <i v-if="type==1" class="ri-bar-chart-fill"></i>
                <i v-if="type==2" class="ri-user-2-fill"></i>
                <i v-if="type==3" class="ri-edit-2-fill"></i>
              </span>
            </div>
            <div class="pointer" @click="logDetail(data)">
              <div>
                <h5 class="font-size-13">
                  {{data.date}}
                  <small class="text-muted">{{data.time}}</small>
                </h5>
              </div>
              <div>
                <p class="text-muted mb-0">{{data.title}}</p>
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <journalModal ref="journalModal" />
  </div>
</template>